<div id="content">       

    <? if(is_array($response)){?>
    <div class="response"> 
        <span class="<?=$response["class"]?>"><?=$response["msg"]?></span>
    </div>
    <?}?>

    <a class="button" href="<?=site_url('admin/categories/add')?>" style="float:right">ADD NEW CATEGORY</a>
    <h1>Product Categories</h1>


    <div class="live_search_msg"></div>
    <? foreach($list as &$item){ ?>

        <? if($item["Parent_Categories"] == NULL){ ?>
        <div class="list_block search <?=($item['Active_Categories']=='1')?'active':'inactive'?>">     
            <a href="<?=site_url('admin/categories/preview/'.$item['id_Categories'])?>" rel="view">
            <span class="title">
                <?=$item['Title_Categories']?>
            </span>
            </a>           
            
            <div class="buttons_block">
                <a href="<?=site_url('admin/categories/edit/'.$item['id_Categories'])?>" class="button">edit</a>
                <? if ($item['Active_Categories'] == 1){?>
                <a href="<?=site_url('admin/categories/deactivate/'.$item['id_Categories'])?>" class="button">deactivate</a>
                <? } else { ?> 
                <a href="<?=site_url('admin/categories/activate/'.$item['id_Categories'])?>" class="button">activate</a>
                <? } ?>

                <? if ($item["id_Categories"] !== ONE_OFF_CAT_ID) { ?>
                <a href="<?=site_url('admin/categories/remove/'.$item['id_Categories'])?>" class="button">delete</a>
                <? } ?>
                
            </div>

        </div>
        <? } ?>

        <? foreach($list as &$subitem){ ?>

            <? if($subitem["Parent_Categories"] == $item["id_Categories"]){ ?>    

                <div class="list_block search <?=($subitem['Active_Categories']=='1')?'active':'inactive'?>">     
                    <a href="<?=site_url('admin/categories/preview/'.$subitem['id_Categories'])?>" rel="view">
                    <span class="title" style="width:450px;padding-left:30px"><?=$subitem['Title_Categories']?></span>
                    </a>           

                    <div class="buttons_block">                                         
                        <a href="<?=site_url('admin/categories/edit/'.$subitem['id_Categories'])?>" class="button">edit</a>
                        <? if ($subitem['Active_Categories'] == 1){?>
                        <a href="<?=site_url('admin/categories/deactivate/'.$subitem['id_Categories'])?>" class="button">deactivate</a>
                        <? } else { ?> 
                        <a href="<?=site_url('admin/categories/activate/'.$subitem['id_Categories'])?>" class="button">activate</a>
                        <? } ?>
                        <a href="#" class="button">delete</a>
                    </div>
                </div>                

            <? unset($subitem); ?>

            <? } ?>

        <? } ?>
              
    <? unset($item); ?>

    <? } ?>

</div>